<#assign pojo=oneToManyPojo.getOne()>
<#assign many=oneToManyPojo.getMany()>
<#assign ones=oneToManyPojo.getOnes()>
<#assign module=oneToManyPojo.getModule()>
<#assign fields=pojo.getFilterdPojoFields()>
<#assign declarationName = pojo.importType(pojo.getDeclarationName())>
<#assign declarationNameFirstLetterLower = pojo.importType(pojo.getDeclarationNameFirstLetterLower())>
<#assign realPackageAndClassPath = "${pojo.getRealPackageAndClassPath()}">
<#assign masterid = pojo.getDeclarationNameFirstLetterLower()+"Id">
import React from "react";
import {routerRedux} from "dva/router";

export default function get${declarationName}SelectConfig(location, dispatch, ${declarationNameFirstLetterLower}, loading,${declarationNameFirstLetterLower}SelectVisible,on${declarationName}Selected,on${declarationName}SelectedCancel) {
  const {${declarationNameFirstLetterLower}DataSource, ${declarationNameFirstLetterLower}Pagination, ${declarationNameFirstLetterLower}Item, modalType, ${declarationNameFirstLetterLower}Rxpand, ${declarationNameFirstLetterLower}SelectedRowKeys,} = ${declarationNameFirstLetterLower}
  const {pageSize} = ${declarationNameFirstLetterLower}Pagination
  const ${declarationNameFirstLetterLower}FilterProps = {
    expand: ${declarationNameFirstLetterLower}Rxpand,
    filter: {
      ...location.query,
    },
    onFilterChange (value) {
      dispatch(routerRedux.push({
        pathname: location.pathname,
        query: {
          ...value,
          pageIndex: 1,
          pageSize,
        },
      }))
    },
    onSearch (fieldsValue) {
      fieldsValue.keyword.length ? dispatch(routerRedux.push({
        pathname: '/${declarationNameFirstLetterLower}',
        query: {
          field: fieldsValue.field,
          keyword: fieldsValue.keyword,
        },
      })) : dispatch(routerRedux.push({
        pathname: '/${declarationNameFirstLetterLower}',
      }))
    },
    switchExpand () {
      dispatch({type: '${declarationNameFirstLetterLower}/switchExpand'})
    },
  }
  const ${declarationNameFirstLetterLower}ListProps = {
    dataSource: ${declarationNameFirstLetterLower}DataSource,
    loading: loading.effects['${declarationNameFirstLetterLower}/query'],
    pagination: ${declarationNameFirstLetterLower}Pagination,
    location,
    onChange (page) {
      const {query, pathname} = location
      dispatch(routerRedux.push({
        pathname: pathname,
        query: {
          ...query,
          pageIndex: page.current,
          pageSize: page.pageSize
        }
      }))
    },
    rowSelection: {
      ${declarationNameFirstLetterLower}SelectedRowKeys,
      onChange: (keys, rows) => {
        dispatch({
          type: '${declarationNameFirstLetterLower}/updateState',
          payload: {
            ${declarationNameFirstLetterLower}SelectedRowKeys: keys,
            ${declarationNameFirstLetterLower}SelectedRows: rows,
          },
        })
      },
    },
    columns: [
<#assign fields=pojo.getFilterdPojoFields()>
<#foreach field in fields>
    <#if field.getIsSampleField()>
      {
        title: '<#if field.getComment()?exists>${field.getComment()}<#else>${field.getName()}</#if>',
        dataIndex: '${field.getName()}',
        key: '${field.getName()}',
      },
    </#if>
</#foreach>
    ]
  }
  const ${declarationNameFirstLetterLower}SelectModalProps = {
    item: modalType == 'create' ? {} : ${declarationNameFirstLetterLower}Item,
    visible: ${declarationNameFirstLetterLower}SelectVisible,
    maskClosable: false,
    key: '${declarationNameFirstLetterLower}' + ${declarationNameFirstLetterLower}Item.id,
    confirmLoading: loading.effects['${declarationNameFirstLetterLower}/update'],
    title: `${r"${"}modalType === 'create' ? 'Create ${declarationName}' : 'Update ${declarationName}'}`,
    wrapClassName: 'vertical-center-modal',
    onOk (data) {
      on${declarationName}Selected(${declarationNameFirstLetterLower}SelectedRowKeys)
    },
    onCancel () {
      on${declarationName}SelectedCancel();
    },
  }
  return {
    ${declarationNameFirstLetterLower}FilterProps,
    ${declarationNameFirstLetterLower}ListProps,
    ${declarationNameFirstLetterLower}SelectModalProps,
  }
}
